package com.sw.code4j.vo;

import com.sw.code4j.common.StringUtils;
import com.gwssi.fusion.datamodel.bo.TDmTableBO;
import com.gwssi.optimus.mongo.util.TransColumnNameToCamel;
import lombok.Data;

/**
 * @author: 张上亚 2021/11/30 11:28
 * @desc: 表信息vo类
 */
@Data
public class TableVO extends TDmTableBO {

    public TableVO(String tableName, String tableComment) {
        setTableName(tableName);
        setTableComment(tableComment);
        this.boPrefix = StringUtils.upperFirst(TransColumnNameToCamel.underlineToCamel(tableName));
        int index = tableName.indexOf("_", tableName.indexOf("_") + 1);
        this.columnPrefix = tableName.substring(index + 1);
        this.attrPrefix = TransColumnNameToCamel.underlineToCamel(columnPrefix);
        this.controllerUrl = attrPrefix.toLowerCase();
        this.controllerPrefix = StringUtils.upperFirst(attrPrefix);
    }

    /**
     * BO类名前缀
     */
    private String boPrefix;
    /**
     * Controller请求url片段
     */
    private String controllerUrl;
    /**
     * Controller类名前缀
     */
    private String controllerPrefix;

    /**
     * Controller属性名前缀
     */
    private String attrPrefix;

    /**
     * 列名前缀
     */
    private String columnPrefix;

}
